{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "initial_id",
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": ""
  },
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": [
    "# 调用总结：\n",
    "###  第一步：大模型的实例：非对话类和对话类\n",
    "###  第二步: 提示词模板的对象：PrompTemplate(template='',input_variables=[\"\"]  /from_template)\n",
    "###  第三步: 将提示词模板对象中的变量进行赋值: format()/invoke();  pratial()\n",
    "###  第四步:将填充完变量以后的调用结构传入大模型的invoke(PromptValue/str中)"
   ],
   "id": "ed210d0d29919d3f"
  },
  {
   "metadata": {},
   "cell_type": "code",
   "outputs": [],
   "execution_count": null,
   "source": " # 非对话类 OpenAI  \\ 对话类: ChatOpenAI",
   "id": "6fdb8d37bae72156"
  },
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": [
    "非对话类 传入的参数类型： str/ prompt_value          ;    返回的类型是: str\n",
    "对话类   传入的参数类型： str/ prompt_value /list[]  ;    返回的类型是: AIMessage"
   ],
   "id": "a2bfde3db34a4522"
  },
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": [
    "###  ② 两种特殊的结构：部分提示词模板（掌握）；组合提示词的使用（了解）\n",
    "\n",
    "① 部分提示词模板的使用"
   ],
   "id": "356e7552f98f82d2"
  },
  {
   "metadata": {},
   "cell_type": "code",
   "outputs": [],
   "execution_count": null,
   "source": [
    "#1.导入相关的包\n",
    "from langchain_core.prompts import PromptTemplate\n",
    "template = PromptTemplate.from_template(\n",
    "    template=\"请评价{product}的优缺点，包括{aspect1}和{aspect2}。\",\n",
    "    partial_variables={\"aspect2\":\"拍照质量\"}\n",
    ")\n",
    "\n",
    "result = template.format(product=\"智能手机\", aspect1=\"电池续航\",)\n",
    "# result = template.format(product=\"智能手机\", aspect1=\"电池续航\",aspect2=\"拍照质量111\")\n",
    "print(result)"
   ],
   "id": "3e7e3a3a51446ad3"
  },
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": "",
   "id": "6e8cfafe0564d3e7"
  },
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": "",
   "id": "106c5944ca6a9880"
  },
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": " PromptTemplate.from_template",
   "id": "2a4755d754848e30"
  },
  {
   "metadata": {},
   "cell_type": "code",
   "outputs": [],
   "execution_count": null,
   "source": "",
   "id": "949ee131c969ed2"
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
